package com.example.demo.entity;

import java.util.Date;

public class MonitorcodeInfo {
    private String monitorcodeId;

    private String monitorcodeDesc;

    private String monitorobjType;

    private String ipAddress;

    private Integer netport;

    private String url;

    private String databaseType;

    private String otherinfo;

    private String remark;

    private String effective;

    private Date updatetime;

    private Date lastexecutetime;

    public String getMonitorcodeId() {
        return monitorcodeId;
    }

    public void setMonitorcodeId(String monitorcodeId) {
        this.monitorcodeId = monitorcodeId == null ? null : monitorcodeId.trim();
    }

    public String getMonitorcodeDesc() {
        return monitorcodeDesc;
    }

    public void setMonitorcodeDesc(String monitorcodeDesc) {
        this.monitorcodeDesc = monitorcodeDesc == null ? null : monitorcodeDesc.trim();
    }

    public String getMonitorobjType() {
        return monitorobjType;
    }

    public void setMonitorobjType(String monitorobjType) {
        this.monitorobjType = monitorobjType == null ? null : monitorobjType.trim();
    }

    public String getIpAddress() {
        return ipAddress;
    }

    public void setIpAddress(String ipAddress) {
        this.ipAddress = ipAddress == null ? null : ipAddress.trim();
    }

    public Integer getNetport() {
        return netport;
    }

    public void setNetport(Integer netport) {
        this.netport = netport;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url == null ? null : url.trim();
    }

    public String getDatabaseType() {
        return databaseType;
    }

    public void setDatabaseType(String databaseType) {
        this.databaseType = databaseType == null ? null : databaseType.trim();
    }

    public String getOtherinfo() {
        return otherinfo;
    }

    public void setOtherinfo(String otherinfo) {
        this.otherinfo = otherinfo == null ? null : otherinfo.trim();
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark == null ? null : remark.trim();
    }

    public String getEffective() {
        return effective;
    }

    public void setEffective(String effective) {
        this.effective = effective == null ? null : effective.trim();
    }

    public Date getUpdatetime() {
        return updatetime;
    }

    public void setUpdatetime(Date updatetime) {
        this.updatetime = updatetime;
    }

    public Date getLastexecutetime() {
        return lastexecutetime;
    }

    public void setLastexecutetime(Date lastexecutetime) {
        this.lastexecutetime = lastexecutetime;
    }

    public String vaildSelfRequriedAtrribute() {
        if(monitorcodeDesc==null||"".equals(monitorcodeDesc)){
            return "monitorobjName cannot be empty";
        }
        if(monitorobjType==null||"".equals(monitorobjType)){
            return "monitorobjType cannot be empty";
        }
        switch (monitorobjType){
            case "databaseAccess":
                if(databaseType==null||"".equals(databaseType)){
                    return "databaseAccess databaseType cannot be empty";
                }
                if(otherinfo==null||"".equals(otherinfo)
                        ||!otherinfo.contains("username")||!otherinfo.contains("password")){
                    return "databaseAccess otherinfo should offer username and password in a json String format like {username:'username',password:'password'}";
                }
            case "webServiceAccess":
                if(url==null||"".equals(url)){
                    return "databaseAccess/webServiceAccess url cannot be empty";
                }
                break;
            case "portAccess":
                if(netport==null||"".equals(netport)){
                    return "portAccess netport cannot be empty";
                }
            case "ipAccess":
                if(ipAddress==null||"".equals(ipAddress)){
                    return "portAccess/ipAddress ipAddress cannot be empty";
                }
                break;
        }
        return "success";
    }
}